﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
//
using OsPortal;
using System.Data.SqlClient;
using System.Data;

/// <summary>
/// Summary description for clsLinkHay
/// </summary>
public class clsLinkHay
{
    static string strClassName = "clsLinkHay";


    public struct stLinkHay
    {
        public String strUS_ID;
        public String strLI_ANCHORTEXT;
        public String strLI_LINK;
        public String strLI_DESCRIPTION;
        public String strLI_IMG;
    }


	public clsLinkHay()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    public static bool LINKHAY_ACT(clsLinkHay.stLinkHay objLinkHay, out string strError)
    {
        try
        {
            DataTable tblResult;
            tblResult = oSqlDataHelper.sExecuteDataTable("LINKHAY_ACT", new SqlParameter[]{
                                                    new SqlParameter("@US_ID",objLinkHay.strUS_ID)
                                                    ,new SqlParameter("@LI_ANCHORTEXT",objLinkHay.strLI_ANCHORTEXT)
                                                    ,new SqlParameter("@LI_LINK",objLinkHay.strLI_LINK)
                                                    ,new SqlParameter("@LI_IMG",objLinkHay.strLI_IMG)
                                                    ,new SqlParameter("@LI_DESCRIPTION",objLinkHay.strLI_DESCRIPTION)
            });
            if (tblResult == null){strError = "";return true;}
            if (tblResult.Rows.Count <= 0)
            {strError = "";return true;}
            //
            strError = OsPortal.oStringHelper.fncCnvNullToString(tblResult.Rows[0]["ERRNAME"]);
            return false;
        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName, "LINKHAY_ACT", ex.ToString());
            strError = "";
            return false;
        }

    }

    public static DataSet LINKHAY_FND(int iCurrPage
                                        , int iPageSize)
    {
        DataSet dtData = null;
        try
        {
            dtData = oSqlDataHelper.sExecuteDataSet("LINKHAY_FND", new SqlParameter[]{
                new SqlParameter("@P_CURRPAGE",iCurrPage)
                ,new SqlParameter("@P_PAGESIZE",iPageSize)
            });
            return dtData;
        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName, "LINKHAY_FND", ex.ToString());
            return null;
        }
        finally
        {
            //dtData.Dispose();
        }
    }


}